package com.molichuxing.gateway.bff.basic.convertor;

import com.molichuxing.framework.dto.UploadFileRequestDto;
import com.molichuxing.gateway.bff.basic.entity.response.*;
import com.molichuxing.services.business.dto.response.OrderScheduleOfflineBizDto;
import com.molichuxing.services.business.dto.response.StoreInfoBizDto;
import com.molichuxing.services.infrastructure.dto.response.*;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Convert {

    public static List<CityInitialVo> toRegionList(Map<String, List<RegionDto>> regionDtoMap) {
        List<CityInitialVo> list = null;
        if (regionDtoMap != null && !regionDtoMap.isEmpty()) {
            list = new ArrayList<>();
            for (Map.Entry<String, List<RegionDto>> entry : regionDtoMap.entrySet()) {
                String key = entry.getKey();
                List<RegionDto> value = entry.getValue();
                List<RegionVo> regionVos = toRegionVo(value);
                CityInitialVo cityInitialVo = new CityInitialVo();
                cityInitialVo.setInitial(key);
                cityInitialVo.setCitys(regionVos);
                list.add(cityInitialVo);
            }
        }
        return list;
    }

    public static List<RegionVo> toRegionVo(List<RegionDto> dtoList) {
        List<RegionVo> voList = null;
        if (dtoList != null && !dtoList.isEmpty()) {
            voList = new ArrayList<>();
            for (RegionDto regionDto : dtoList) {
                voList.add(toRegionVo(regionDto));
            }
        }
        return voList;
    }

    public static RegionVo toRegionVo(RegionDto regionDto) {
        RegionVo beanVo = null;
        if (regionDto != null) {
            beanVo = new RegionVo();
            BeanUtils.copyProperties(regionDto, beanVo);
            beanVo.setRegionId(regionDto.getId());
        }

        return beanVo;
    }


    public static List<CarBaseConfVo> toCarBaseConfVo(List<CarBaseConfDto> dtoList) {
        List<CarBaseConfVo> voList = null;
        if (dtoList != null && !dtoList.isEmpty()) {
            voList = new ArrayList<>();
            for (CarBaseConfDto regionDto : dtoList) {
                voList.add(toCarBaseConfVo(regionDto));
            }
        }
        return voList;
    }

    public static CarBaseConfVo toCarBaseConfVo(CarBaseConfDto regionDto) {
        CarBaseConfVo beanVo = null;
        if (regionDto != null) {
            beanVo = new CarBaseConfVo();
            BeanUtils.copyProperties(regionDto, beanVo);
        }

        return beanVo;
    }

    public static VersionMobileVo toVersionMobileVo(VersionMobileDto beanDto) {
        VersionMobileVo beanVo = null;
        if (beanDto != null) {
            beanVo = new VersionMobileVo();
            BeanUtils.copyProperties(beanDto, beanVo);
        }

        return beanVo;
    }
    
    public static UploadFileRequestDto toUploadFileRequestDto(FileStorageConfigDto beanDto) {
		UploadFileRequestDto beanVo = null;
		if (beanDto != null) {
			beanVo = new UploadFileRequestDto();
			BeanUtils.copyProperties(beanDto, beanVo);
		}
		return beanVo;
	}

    public static List<RegionCityVo> toRegionCityVoList(List<RegionCityDto> beanList) {
        List<RegionCityVo> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (RegionCityDto bean : beanList) {
                dtoList.add(toRegionCityVo(bean));
            }
        }
        return dtoList;
    }

    public static RegionCityVo toRegionCityVo(RegionCityDto bean) {
        RegionCityVo beanDto = null;
        if (bean != null) {
            beanDto = new RegionCityVo();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }


    public static List<DeliveryParamDicVo> toDeliveryParamDicVoList(List<DeliveryParamDicDto> beanList) {
        List<DeliveryParamDicVo> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (DeliveryParamDicDto bean : beanList) {
                dtoList.add(toDeliveryParamDicVo(bean));
            }
        }
        return dtoList;
    }

    public static DeliveryParamDicVo toDeliveryParamDicVo(DeliveryParamDicDto dto) {
        DeliveryParamDicVo beanDto = null;
        if (dto != null) {
            beanDto = new DeliveryParamDicVo();
            BeanUtils.copyProperties(dto, beanDto);
        }
        return beanDto;
    }



}
